package com.huahua.bigdata.sparksql;

import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;

public class SparkSQL04_Source_CSV {
    public static void main(String[] args) {
        final SparkSession sparkSession = SparkSession
                .builder()
                .master("local[*]")
                .appName("SparkSQL")
                .getOrCreate();
        // TODO CSV文件就是将数据采用逗号分隔的数据文件
        Dataset<Row> csv = sparkSession.read()
                .option("header", "true")   // 配置
                .option("sep", ",")
                .csv("data/user.csv");

        csv.write().csv("output");

        // TODO 释放资源
        sparkSession.close();
    }
}
